# 设置基本变量
OUTPUT_DIR=output

# 帮助信息
.PHONY: help
help:
	@echo "comsdk 服务组件SDK 构建工具"
	@echo ""
	@echo "可用命令:"
	@echo "  help              显示此帮助信息"
	@echo "  test              运行所有测试"
	@echo "  build-examples    构建示例应用"
	@echo "  run-example       运行示例应用"
	@echo "  lint              检查代码质量 (go vet, go fmt)"
	@echo "  clean             清理构建文件"
	@echo "  release           交互式选择发布版本"
	@echo "  release-patch     发布补丁版本 (1.0.0 -> 1.0.1)"
	@echo "  release-minor     发布次要版本 (1.0.0 -> 1.1.0)"
	@echo "  release-major     发布主要版本 (1.0.0 -> 2.0.0)"
	@echo ""
	@echo "使用示例: make test"

# 默认目标：显示帮助
.DEFAULT_GOAL := help

# 运行测试
.PHONY: test
test:
	go test -v ./...

# 构建示例
.PHONY: build-examples
build-examples:
	go build -v ./example/...

# 发布目标
.PHONY: release
release:
	./scripts/release.sh

# 发布补丁版本 (1.0.0 -> 1.0.1)
.PHONY: release-patch
release-patch:
	./scripts/release.sh --patch

# 发布次要版本 (1.0.0 -> 1.1.0)
.PHONY: release-minor
release-minor:
	./scripts/release.sh --minor

# 发布主要版本 (1.0.0 -> 2.0.0)
.PHONY: release-major
release-major:
	./scripts/release.sh --major

# 清理构建文件
.PHONY: clean
clean:
	rm -rf $(OUTPUT_DIR)

# 检查代码质量
.PHONY: lint
lint:
	go vet ./...
	go fmt ./...

# 运行示例
.PHONY: run-example
run-example:
	cd example && go run main.go 